package com.drico.grafo;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;

public class Grafo {

	private ArrayList<String> names;
	private Hashtable<String, Vertex> vertexs;

	public Grafo() {
		names = new ArrayList<String>();
		vertexs = new Hashtable<String, Vertex>();
	}

	public Vertex getVertex(String name) {
		return vertexs.get(name);
	}

	public void addVertex(String nombre) {
		names.add(nombre);
		vertexs.put(nombre, new Vertex(nombre));
	}

	public void addEdge(String start, String end, int weigth) {
		vertexs.get(start).addAdjacencies(new Edge(vertexs.get(end), weigth));
	}

	public void cleanDistances() {
		Enumeration<Vertex> e = vertexs.elements();
		while (e.hasMoreElements())
			e.nextElement().clean();
	}

	public ArrayList<String> getNombres() {
		return names;
	}

	public void setNombres(ArrayList<String> nombres) {
		this.names = nombres;
	}

	public Hashtable<String, Vertex> getVertexs() {
		return vertexs;
	}

	public void setVertexs(Hashtable<String, Vertex> vertexs) {
		this.vertexs = vertexs;
	}

}
